<?php
/**
 * 测试添加公司员工功能
 */

// 测试数据
$testData = [
    'phone' => '13800138000' // 替换为实际的手机号进行测试
];

echo "=== 测试添加公司员工功能 ===\n";
echo "接口地址: POST /v1/company/add-member\n";
echo "请求参数:\n";
echo json_encode($testData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n\n";

// 发起请求
$url = 'http://localhost:8787/v1/company/add-member';
$headers = [
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_ACCESS_TOKEN' // 替换为实际的token
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['data' => $testData]));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "HTTP状态码: $httpCode\n";
echo "响应内容:\n";
echo $response . "\n\n";

// 解析响应
$result = json_decode($response, true);
if ($result) {
    if ($result['code'] === 1) {
        echo "✅ 测试成功: " . $result['msg'] . "\n";
        if (isset($result['data']['user'])) {
            echo "添加的员工信息:\n";
            echo "  ID: " . $result['data']['user']['id'] . "\n";
            echo "  昵称: " . $result['data']['user']['nickname'] . "\n";
            echo "  手机号: " . $result['data']['user']['phone'] . "\n";
        }
    } else {
        echo "❌ 测试失败: " . $result['msg'] . "\n";
    }
} else {
    echo "❌ 响应解析失败\n";
}

echo "\n=== 测试完成 ===\n";
?> 